<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/mytemplate.js"></script>
</head>
<body>
    <div id="user-box"></div>
    <!-- 预定义模板 -->
    <script type="text/html" id="user-panel">
        <div>user: {{user}}</div>
        <div>password: {{password}}</div>
    </script>
    <script>
        var data = {user:'小红',password:'123456'};
        var str = mytemplate('user-panel',data);
        document.querySelector("#user-box").innerHTML=str;
    </script>
</body>
</html>